package com.lijiajian.Service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.lijiajian.base.BaseService;
import com.lijiajian.dao.OrderDetailsMapper;
import com.lijiajian.pojo.CustomerOrder;
import com.lijiajian.pojo.OrderDetails;
import com.lijiajian.query.CustomerOrderQuery;
import com.lijiajian.query.OrderDetailsQuery;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class OrderDetailsService extends BaseService<OrderDetails,Integer> {
    @Resource
    private OrderDetailsMapper orderDetailsMapper;

    public List<Float> getSum(Integer orderId){
        return orderDetailsMapper.querySum(orderId);
    }

    /**
     * 多条件查询订单详情
     * @param
     * @return
     */
    public Map<String,Object> queryOrderDetailsByParams(OrderDetailsQuery orderDetailsQuery){
        Map<String,Object> map=new HashMap<>();
        //开启分页
        PageHelper.startPage(orderDetailsQuery.getPage(),orderDetailsQuery.getLimit());
        PageInfo<OrderDetails> pageInfo=new PageInfo<>(orderDetailsMapper.selectByParams(orderDetailsQuery));
        map.put("code",0);
        map.put("msg","success");
        map.put("count",pageInfo.getTotal());
        map.put("data",pageInfo.getList());

        return map;
    }
}
